<%-- 
    Document   : products
    Created on : Nov 25, 2011, 8:08:22 PM
    Author     : user
--%>

<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Utils.Static"%>
<%@page import="java.sql.ResultSet"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%@include file="../jspf/header.jspf" %>
   
<div style="width: 100%">
    <p class="pageTitle"><strong>Produse</strong></p>
    <br />
    <div class="txt1" style="width: 100%"><b>Stoc produse</b>
        <hr />
    </div>
    <%@include file="../jspf/message.jspf" %>

    <div>
        <div class="txt1" style="float: left; margin-top: 13px"><!--
        <p><b> Categorie: </b> <select name="categories" >
        <?php

        $categories = $_SESSION['categories'];
        unset($_SESSION['categories']);

        foreach($categories as $cat)
        {
	echo '<option value="'.$cat['CategoryID'].'">'.$cat['Name'].'</option>';
        }

        ?>
        </select></p> --></div>

        <div class="divPaginare">
            
            <%
                        session.setAttribute(Static.pageSort, "products");
            %>

            <%@include file="../jspf/sort.jspf" %>
            <%@include file="../jspf/pagining.jspf" %>
            
        </div>

    </div>
    <div style="width: 100%; margin-top: 15px">
        <hr />
    </div>
    <div style="width: 100%; padding: 10px 0px 10px 0px">
        <table style="width: 100%" class="data">
            <tr>
                <th><input name="hOptiune" id="hOptiune" value="Optiune"
                           readonly="readonly" /></th>
                <th><input name="hProduct" id="hProduct" value="Produs" class="large"
                           readonly="readonly" /></th>
                <th><input class="large" name="hCategory" id="hCategory"
                           value="Categorie" readonly="readonly" /></th>
                <th><input name="hProduct" id="hPrice" value="Pret"
                           readonly="readonly" /></th>
                <th><input name="hProduct" id="hQuantity" value="Cantitate"
                           readonly="readonly" /></th>
                <th><input class="large" name="hQuantitys" id="hQuantity"
                           value="Descriere" readonly="readonly" /></th>
            </tr>


            <%

                        try {

                            ArrayList products = (ArrayList) session.getAttribute(Static.products);
                            // session.setAttribute(Static.products, null);

                            int size = products.size();

                            for (int i = 0; i < size; i++) {
                                HashMap row = (HashMap) products.get(i);

                                out.println("<td>");
                                out.println("<a href=\"admin/products?action=edit&id=" + row.get("ProductID") + "\"><img alt=\"?\" id=\"edit\" title=\"editeaza\" src=\"img/site/edit.png\" ></img></a>");
                                out.println("&nbsp;&nbsp;");
                                out.println("<a href=\"admin/products?action=delete&id=" + row.get("ProductID") + "\"><img alt=\"?\" id=\"delete\" title=\"sterge\" src=\"img/site/delete.png\" ></a>");
                                out.println("</td>");
                                out.println("<td>");
                                out.println("<input class=\"large\" name=\"hProduct\" Title=\"" + row.get("Name") + "\" id=\"Text1\" value=\"" + row.get("Name") + "\" readonly=\"readonly\" /> ");
                                out.println("</td>");
                                out.println("<td>");
                                out.println("<input class=\"large\" name=\"hCategory\" id=\"Text4\" Title=\"" + row.get("CategoryName") + "\" value=\"" + row.get("CategoryName") + "\" readonly=\"readonly\" />");
                                out.println("</td>");
                                out.println("<td>");
                                out.println("<input  name=\"hProduct\" id=\"Text2\" Title=\"" + row.get("Price") + "\" value=\"" + row.get("Price") + "\" readonly=\"readonly\" />");
                                out.println("</td>");
                                out.println("<td>");
                                out.println("<input  name=\"hQuantity\" id=\"Text3\" Title=\"" + row.get("Quantity") + "\" value=\"" + row.get("Quantity") + "\" readonly=\"readonly\" />");
                                out.println("</td>");
                                out.println("<td>");
                                out.println("<input class=\"large\" name=\"hDescription\" id=\"Text4\" Title=\"" + row.get("Description") + "\" value=\"" + row.get("Description") + "\" readonly=\"readonly\" />");
                                out.println("</td>");
                                out.println("</tr>");
                            }
                        } catch (Exception ex) {
                            out.println(ex.getMessage());
                        }
            %>

        </table>
    </div>
    <div></div>

    <div class="divProductsList Bottom">
        <hr />

    </div>
    <div>
        <div>
            <div style="float: left;"><a
                    href="admin/products?action=add"> <input name="Update"
                                                                         type="submit" class="button" size="30" value="Adauga produs" /></a>
                <a
                    href="admin/products.jsp?action=export"> <input name="Export"
                                                                            type="submit" class="button" size="30" value="Exporta" /></a>
                <a
                    href="admin/products.jsp?action=import"> <input name="Import"
                                                                            type="submit" class="button" size="30" value="Importa" /></a>
            </div>
        </div>
        <div class="divPaginare" style="text-align: right">

            <%
                        session.setAttribute(Static.pageSort, null);
                        session.setAttribute(Static.page, null);
                        session.setAttribute(Static.pageDir, null);
                        session.setAttribute(Static.firstPage, null);
                        session.setAttribute(Static.currPage, null);
                        session.setAttribute(Static.pageCount, null);
            %>
        </div>
    </div>
</div>

<%@include file="../jspf/footer.jspf" %>